<template>
  <div class="app-container">
    <el-drawer
      :title="title"
      :visible.sync="openDetail"
      size="80%"
      @close="cancel"
      :append-to-body="true"
    >
      <div style="padding: 0 20px">
        <el-tag size="large" style="font-size: 20px">基本信息</el-tag>
        <hr />
        <el-row :gutter="20">
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <span>领料单编号:</span>
              <span>{{ form.issueCode }}</span>
            </div>
          </el-col>
          <el-col :span="6">
            <div class="grid-content bg-purple">
              <span>领料单名称:</span>
              <span>{{ form.issueName }}</span>
            </div>
          </el-col>
          <el-col :span="6">
            <div class="grid-content bg-purple">
              <span>仓库名称：</span>
              <span>{{ form.warehouseCode }}</span>
            </div>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <span>仓库编码:</span>
              <span>{{ form.warehouseId }}</span>
            </div>
          </el-col>
          <el-col :span="6">
            <div class="grid-content bg-purple">
              <span>领料日期:</span>
              <span>{{ form.issueDate }}</span>
            </div>
          </el-col>
          <el-col :span="6">
            <div class="grid-content bg-purple">
              <span>单据状态:</span>
              <span>{{ form.status }}</span>
            </div>
          </el-col>
        </el-row>
        <hr />
        <el-tag size="large" style="font-size: 20px; margin-bottom: 10px; margin-top: 10px">物料列表</el-tag>
        <hr />
        <el-table v-loading="loading" :data="routeproductbomList">
          <el-table-column label="序号" align="center" width="150px" prop="issueCode">
            <template slot-scope="scope">
              <span>{{scope.$index + 1}}</span>
            </template>
          </el-table-column>
          <el-table-column label="所属工序" align="center" prop="processName" />
          <el-table-column label="物料编号" align="center" prop="itemCode" />
          <el-table-column label="物料名称" align="center" prop="itemName" />
          <el-table-column label="规格型号" align="center" prop="specification" />
          <el-table-column label="单位" width="100" align="center" prop="measureName" />
          <el-table-column label="用量:分子" width="80" align="center" prop="quantity" />
          <el-table-column label="用量:分母" align="center" prop="productNum" />
          <el-table-column label="领料数量" width="80" align="center" prop="quantityIssued" />
          <!-- <el-table-column label="领料日期" align="center" prop="issueDate" width="180" >
              <template slot-scope="scope">
                <span>{{
                  parseTime(scope.row.issueDate, "{y}-{m}-{d} {h}:{m}:{s}")
                }}</span>
              </template>
          </el-table-column>-->
          <!-- <el-table-column label="单据状态" align="center" prop="status">
              <template slot-scope="scope">
                <dict-tag
                  :options="dict.type.mes_workorder_status"
                  :value="scope.row.status"
                />
              </template>
          </el-table-column>-->
        </el-table>
      </div>
    </el-drawer>
  </div>
</template>
  
  <script>
import { listIssuedetail } from "@/api/mes/wm/issueDetail";
export default {
  data() {
    return {
      openDetail: false,
      title: "查看领料单",
      // 表单参数
      form: {},
      loading: false,
      routeproductbomList: []
    };
  },
  methods: {
    //初始化函数
    init(row) {
      console.log(row, "子组件的row");
      this.form = row;
      //调接口需要的id
      this.workorderId = row.workorderId;
      this.openDetail = true;
      this.getList();
    },
    getList() {
      listIssuedetail(this.workorderId).then(res => {
        console.log(res, "详情table的res");
        if (res.code == 200) {
          this.routeproductbomList = res.rows;
        }
      });
    },
    // 取消按钮
    cancel() {
      this.openDetail = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        workorderId: null,
        workorderCode: null,
        workorderName: null,
        orderSource: null,
        sourceCode: null,
        productId: null,
        productCode: null,
        productName: null,
        productSpc: null,
        unitOfMeasure: null,
        quantity: null,
        quantityProduced: null,
        quantityChanged: null,
        quantityScheduled: null,
        clientId: null,
        clientCode: null,
        clientName: null,
        requestDate: null,
        parentId: null,
        status: 0,
        remark: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        orderType: null,
        fPlanStartDate: null,
        fPlanFinishDate: null
      };
      this.autoGenFlag = false;
      this.resetForm("form");
    }
  }
};
</script> 
  <style rel="stylesheet/scss" lang="scss" scoped>
.app-container ::v-deep .el-drawer__header {
  padding-top: 10px !important;
  padding-bottom: 5px !important;
  margin-bottom: 10px !important;
}
</style>